#pragma once

#ifndef GAMESTATE_H_
#define GAMESTATE_H_

#include <list>
#include "Box2D/Box2D.h"
#include "ShaderManager.h"
#include "TextureManager.h"

class GameObject;
class Player;

class GWindow;

class JumpController;
class Floor;


using namespace std;

const double TIMESTEP = 0.001;

class GameState  : public b2ContactListener
{

public:
	GameState();

	~GameState();

	void addObject(GameObject* object);

	void update(double dt);

	void draw();

	virtual void BeginContact(b2Contact* contact);

  virtual void EndContact(b2Contact* contact);

  virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold);

  virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse);

	TextureManager& getTextureManager(){ return m_textureManager;}

	ShaderManager& getShaderManager(){ return m_shaderManager;}

	void setPlayer(Player *player){ m_player = player;}

	Player* getPlayer(){ return m_player; }


	void setGWindow(GWindow *gwindow){ m_gwindow = gwindow;}

	GWindow* getGWindow(){ return m_gwindow; }

  JumpController* getJumpController();
  Floor* getFloor();

  int getCurrentLevel() { return m_currentLevel; }
  int getMaxLevels() { return m_maxLevels; }
  void setCurrentLevel(int level) { m_currentLevel = level; if(level>m_maxLevels) m_currentLevel = 1;}

    bool m_levelCompleted;
private:

	// Object handling
	list<GameObject*> m_objects;

	unsigned int m_nextId;
	
	b2World m_world;

	ShaderManager m_shaderManager;

	TextureManager m_textureManager;

	// Time handling
	double m_currentTime;

	double m_accumulator;

	Player *m_player;


	GWindow *m_gwindow;


  int m_maxLevels;
  int m_currentLevel;




};

#endif
